home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / SPX20.ZIP / SPX_DOC.ZIP / SPX_GUI.DOC < prev    next >
Text File  |  1993-09-27  |  34KB  |  883 lines

  1. { SPX Library Version 2.0  Copyright 1993 Scott D. Ramsay }
  2.  
  3.  SPX_GUI is the Graphical User Interface unit which allows users to create
  4. screens that are similar to the utilites that are included with the SPX
  5. Library.
  6.  
  7.  The unit allows of the easy creation an use of push buttons, radio buttons,
  8. check boxes, string boxes, scroll bars and pick (selecton) boxes.  As well as
  9. popup dialog boxes. Such as the predefined message and yes boxes.
  10.  Some object oriented programming knowledge is nessasary.  Review the unit
  11. SPX_OBJ for more info.
  12.  
  13. ───────────────────────────────────────────────────────────────────────────
  14.  The SPX_GUI has a system palette of 8 colors.  The system colors are saved
  15. in two different arrays:
  16.  
  17.   wcolortypes = array[0..7] of rgbtype;
  18.   vcolortypes = array[0..7] of byte;
  19.   
  20.   menucolors : wcolortypes
  21.   cl         : vcolortypes;
  22.  
  23.   The variable MENUCOLORS contain the red, green, blue values for each of
  24. the system colors.  These are the actual (want) colors for the system palette.
  25.  
  26.   The variable CL contain the index value for each of the system colors.  This
  27. array is used for drawing button objects and screens.  CL is defined by
  28. matching the MENUCOLORS array to closest values in the current VGA palette.
  29.  
  30.   Whenever you change the VGA palette call the procedure adjustmenupalette
  31. to re-map the CL array.
  32.  
  33.   The default system colors can be changed by changing the values in
  34. MENUCOLORS then calling adjustmenupalette to re-map CL.  Once this is done,
  35. you should redraw all objects to use the new values contained in CL.
  36.  
  37.   The default color scheme is a gray color scheme.  SPX_GUI contains another
  38. color scheme called "burntsienna".   To use:
  39.  
  40.     menucolors := burntsienna; { or menucolors := defaultcolors for default }
  41.     adjustmenupalette;
  42.     { redraw objects }
  43.  
  44. ──────────────────────────────────────────────────────────────────────────
  45.  Here is an outline of a sample gui program:
  46.  
  47.       { create list }
  48.       { add objects to list }
  49.       { display visible objects }
  50.        repeat
  51.          { get key and mouse strokes }
  52.          { process key and mouse strokes }
  53.          { check if any objects were activated }
  54.        until { done }
  55.       { deallocate list }
  56.  
  57.  Below is a complete program with two push buttons:
  58.  
  59.    Program MyFirstGUI;
  60.  
  61.    {$X+ } { enable extended syntax }
  62.  
  63.    Uses spx_vga,spx_gui,mouse;
  64.  
  65.    const
  66.      id_cool = 1;               { button handles or id numbers }
  67.      id_quit = 2;
  68.  
  69.    var
  70.      list : TobjList;           { list to contain all objects }
  71.      p,q  : pButton;            { object pointers }
  72.      pr   : integer;
  73.      quit : boolean;
  74.    begin
  75.      openmode(1);               { open the graphics mode }
  76.      cls(cl[1]);                { clear screen to default background color }
  77.     { check if mouse exist, display message if not found }
  78.      if mousereset=0
  79.        then message('Mouse not installed',true)
  80.        else normalizemx;           { check mouse horzontal position }
  81.      list.init;                    { init your object list }
  82.     { add two buttons }
  83.      list.addobject(new(pButton,init(130,100,50,15,id_cool,#32,false,'|SPACE| COOL')));
  84.      list.addobject(new(pButton,init(130,120,50,15,id_quit,#27,false,'|ESC| Quit')));
  85.      with list do
  86.        begin
  87.         { display all objects within LIST }
  88.          showall;
  89.         { turn on mouse if available }
  90.          mouseon;
  91.         { set exit flag }
  92.          quit := false;
  93.         { program loop... }
  94.          repeat
  95.            inkey;                    { grab key and mouse strokes }
  96.            pr := checkpress(p);      { process key and mouse strokes }
  97.           { check if any objects were activated }
  98.            case pr of
  99.              id_cool : message('You activated the |COOL| button',true);
  100.              id_quit : quit := yes('Exit sample?');
  101.            end;
  102.          until quit;
  103.         { turn off mouse if available }
  104.          mouseoff;
  105.        end;
  106.     { deallocate object list }
  107.      list.done;
  108.     { restore video mode }
  109.      closemode;
  110.    end.
  111.  
  112.    In the above example we added two push buttons.  When the first button
  113.  is activated, it displays a message.  The second button displays a dialog
  114.  box asking to quit the program.
  115.    The function CHECKPRESS does most of the calculations.  It processes
  116.  the key and mouse strokes to check if any objects were activated.  If an
  117.  object was activated it will return the object's id/handle number or zero
  118.  if no object was activated.  When an object is activated, the pointer P
  119.  points to that object.  So in the above example you could change the
  120.  following:
  121.  
  122.         .
  123.         .
  124.         .
  125.  
  126.      q := list.addobject(new(pButton,init(130,100,50,15,id_cool,#32,false,'|SPACE| COOL')));
  127.      q^.msg := 'This is the cool button';
  128.      q := list.addobject(new(pButton,init(130,120,50,15,id_quit,#27,false,'|ESC| Quit')));
  129.      q^.msg := 'This is the exit button';
  130.         .
  131.         .
  132.         .
  133.      case pr of
  134.        id_cool : message(p^.msg,true);
  135.        id_quit : begin
  136.                    message(p^.msg,true);
  137.                    quit := yes('Exit sample?');
  138.                  end;
  139.      end;
  140.  
  141.      The method ADDOBJECT returns a pointer to the object that was just
  142.  added to the list.  Each object has a MSG string variable which can be
  143.  set as an info string.  See below.
  144. ───────────────────────────────────────────────────────────────────────────
  145.  
  146.   All window objects inherited from Tbutton object which is a child object
  147. of Tobjs defined in the SPX_OBJ unit.
  148.  
  149.      Tobjs                         { generic list object from SPX_OBJ.TPU }
  150.       └─Tbutton                    { push button object }
  151.          ├─Tpbox                   { pick "selection" box object }
  152.          ├─Tscroll                 { scroll bar object }
  153.          └─Tstring                 { string "input" box object }
  154.             ├─ Tcheck              { check box object }
  155.             └─ Tradio              { radio button object }
  156.  
  157.   The button objects list is maintained within the object Tobjslist:
  158.  
  159.   Tobjlist = object
  160.                head,tail : plist;
  161.                io        : Pmouse_io;
  162.                focus     : pbutton;
  163.                gmsg      : string;
  164.                orange    : pbutton;
  165.                constructor init;
  166.                procedure inkey;virtual;
  167.                procedure clearbuffer;virtual;
  168.                function addobject(item:Pbutton):Pbutton;virtual;
  169.                function checkpress(var p:pbutton):integer;virtual;
  170.                function retobject(hnd:integer):pbutton;virtual;
  171.                procedure showall;virtual;
  172.                destructor done;virtual;
  173.              end;
  174.  
  175.     HEAD,TAIL    a linked list of button objects
  176.     IO           keyboard, mouse input object.
  177.     FOCUS        a pointer to which object has the current focus, NIL if
  178.                  none.
  179.     GMSG         Set to the last object's MSG variable
  180.     ORANGE       contains the Old RANGE or last object that the mouse
  181.                  passed over
  182.  
  183.     -----------------------------------------------
  184.     constructor init;
  185.  
  186.        Initalize the object structure
  187.  
  188.     -----------------------------------------------
  189.     procedure inkey;virtual;
  190.  
  191.        Reads the keyboard and mouse.  Sets the IO
  192.        object variables.  See SPX_GUI.INT for description
  193.        of variables.
  194.  
  195.     -----------------------------------------------
  196.     procedure clearbuffer;virtual;
  197.  
  198.        Clears the keyboard and mouse input buffers.
  199.     -----------------------------------------------
  200.     function addobject(item:Pbutton):Pbutton;virtual;
  201.  
  202.        Adds an object to the object list.  Returns a pointer to
  203.        the new object.
  204.  
  205.        ITEM  pointer to the object to add to the list.
  206.  
  207.        example:
  208.  
  209.        var
  210.          p : pbutton;
  211.        begin
  212.          list.init;
  213.          p := list.addobject(new(pbutton,init(0,0,40,15,1,#32,false,'SPACE')));
  214.          p^.msg := 'The is button is the SPACE button';
  215.        end;
  216.  
  217.     -----------------------------------------------
  218.     function checkpress(var p:pbutton):integer;virtual;
  219.  
  220.       Searches the linked list processing the key and mouse strokes to check
  221.       if any objects were activated.  If an object was activated, it will
  222.       return the object's id/handle number or zero if no object was activated.
  223.       When an object is activated, the pointer P points to that object.
  224.  
  225.     -----------------------------------------------
  226.     function retobject(hnd:integer):pbutton;virtual;
  227.  
  228.       Returns a pointer to an object by specifiying its ID/handle number.
  229.  
  230.       returns NIL if object can not be found
  231.     -----------------------------------------------
  232.     procedure showall;virtual;
  233.  
  234.       Displays all objects in the linked list
  235.     -----------------------------------------------
  236.     destructor done;virtual;
  237.  
  238.       Deallocates the virtual object.
  239. ───────────────────────────────────────────────────────────────────────────
  240.   Each object is identified by its own unique handle or id number defined
  241. by your program.  An object is activated by the object's hot key or when
  242. the mouse is clicked on the object.  All objects have the basic
  243. description fields:
  244.  
  245.     id            : integer;     { from the object Tobjs }
  246.     idnum         : word;
  247.     tch           : char;
  248.     mmask         : byte;
  249.     attr          : Tattr;
  250.     title         : string;
  251.     titlex,titley : itempos;
  252.     tfunct,
  253.     visible,
  254.     disabled      : boolean;
  255.     cdraw,caction : Tproc_a;
  256.     cnear         : Tproc_b;
  257.     root          : Pobjlist;
  258.     msg           : string;
  259.  
  260.   ----------------------------------------------------------
  261.  
  262.   ID       inherited from Tobjs.  tells the object type:
  263.              id_button = 1;       { button id numbers }
  264.              id_string = 2;
  265.              id_check  = 3;
  266.              id_radio  = 4;
  267.              id_scroll = 5;
  268.              id_pbox   = 6;
  269.  
  270.   IDNUM    object's unique id number
  271.  
  272.   TCH      object's hot key.  Character which activates object.
  273.  
  274.   TFUNCT   TRUE if TCH is an extended character. i.e. a Function key.
  275.  
  276.   MMASK    mouse button mask.  Defines which of the mouse button(s) will
  277.            activate the object. Can be the following values:
  278.                   mLeftButton  = 1;
  279.                   mRightButton = 2;
  280.                   mBothButtons = 3;
  281.  
  282.   ATTR     object's size and position
  283.                 Tattr = record
  284.                           x,y,            { object's top-left position }
  285.                           w,h : integer;  { object's width and height }
  286.                         end;
  287.  
  288.   TITLE    object's name or descriptive title
  289.  
  290.   TITLEX,
  291.   TITLEY   object's title's position within the object. Can be the
  292.            following values:
  293.                   (center,top,left,bottom,right);
  294.  
  295.   VISIBLE  set to TRUE if the object is visible.  If set to FALSE, the
  296.            object will not be drawn.  The object's hot key will still
  297.            activate.  Clicking on its area with the mouse will not
  298.            activate the object
  299.  
  300.   DISABLED set to TRUE to disable the object.  The object will not be
  301.            drawn and the hot key will not activate the object.
  302.  
  303.   CDRAW    Can point user defined procedure.  When pointing to a procedure
  304.            it will use that procedure to draw the object.  CDRAW must
  305.            point to a FAR procedure and have be defined as the following:
  306.  
  307.                 procedure MyCustomDraw(p:pbutton);
  308.  
  309.            This is usefull to create your own object styles.
  310.  
  311.                {$F+ } { declare far }
  312.                 procedure MyCustomDraw(p:pbutton);
  313.                 begin
  314.                   with p^ do
  315.                     begin
  316.                       { draw object here }
  317.                     end;
  318.                 end;
  319.  
  320.   CACTION  Similar to CDRAW.  When overridden, it will be called everytime
  321.            the object is activated.
  322.  
  323.   CNEAR    When overridden, the procedure is called when ever the mouse
  324.            initally passes over the object or the mouse just leaves the
  325.            object.
  326.  
  327.            {$F+ }
  328.            procedure MyCustomBorder(p:pbutton;on:boolean);
  329.            begin
  330.              with p^ do
  331.                if on
  332.                  then { draw object as focused }
  333.                  else { draw object not focused }
  334.            end;
  335.  
  336.   ROOT     a pointer that points to the object's linked list definations
  337.  
  338.   MSG      a string that describes the object.  Usually information that
  339.            will be displayed in an info-bar when the mouse passes over
  340.            the object.
  341. ───────────────────────────────────────────────────────────────────────────
  342. ───────────────────────────────────────────────────────────────────────────
  343. WINDOW OBJECTS
  344. ───────────────────────────────────────────────────────────────────────────
  345. TBUTTON - push button object
  346.  
  347.    constructor init(x,y,w,h,idn:integer;ch:char;fnc:boolean;t:string);
  348.  
  349.      Sets up the push button object.
  350.  
  351.      X,Y    left-top position of the object
  352.      W,H    width and height of the object
  353.      IDN    the object's unique id number
  354.      CH     objects hot-key
  355.      FNC    TRUE if the hot-key is an extended character
  356.      T      title of the object
  357.    ------------------------------------------------------
  358.    procedure drawitemobject;virtual;
  359.  
  360.    Inherited from Tobjs.  Draws the push button.
  361.    If the variable CDRAW is set to a procedure, it will
  362.    call CDRAW to draw the object.
  363.    ------------------------------------------------------
  364.    procedure nearitemobject(on:boolean);virtual;
  365.  
  366.    Processes the event when a mouse moves over an object.  And
  367.    calls the method SHOW to draw/erase a focused button.
  368.  
  369.      ON    TRUE if the mouse just moved over the object. FALSE if
  370.            the mouse just left the object.
  371.  
  372.    If the variable CNEAR is set to a procedure, it will
  373.    call CNEAR to handle the drawing/erasing of an object when the
  374.    mouse passes or leaves.
  375.    ------------------------------------------------------
  376.    procedure actionitemobject;virtual;
  377.  
  378.    This procedure is called whenever an object is activated. It calls
  379.    the method SHOWPRESS. If the variable CACTION is set to a procedure,
  380.    it will call CACTION to handle the action required when the object
  381.    is activated
  382.    ------------------------------------------------------
  383.    procedure showpress;virtual;
  384.  
  385.    This procedure is the code procedure of each object.  It does the
  386.    default action.  For button objects it is an empty procedure.  For
  387.    string objects SHOWPRESS would do the text entry.
  388.    ------------------------------------------------------
  389.    procedure show(on:boolean);virtual;
  390.  
  391.    Draws a focus or unfocused object.
  392.  
  393.    ON   TRUE - if the object is focused (the mouse is over the object)
  394.         FALSE - if the mouse is not over the object.
  395.    ------------------------------------------------------
  396.    function ncheckhit(hx,hy,ohx,ohy:integer;item:pobjlist):boolean;virtual;
  397.  
  398.    Similar to the method CHECKHIT defined in Tobjs.  Checks if the mouse
  399.    is in the object's area or if the hot-key of the object is pressed.
  400.    ------------------------------------------------------
  401.    destructor done;virtual;
  402.  
  403.    Deallocates the virtual object
  404. ───────────────────────────────────────────────────────────────────────────
  405. TSTRING - text entry object
  406.  
  407.    esx,esy,           { width,height of input area within object }
  408.    epx,epy : integer; { (x,y) position of input area with in object }
  409.    objectx,           { Same as TitleX,TitleY sets position of the }
  410.    objecty : itempos; {  input area position with in the object }
  411.    spaceok,           { Set to TRUE to allow SPACES in text entry }
  412.    upper,             { Set to TRUE to allow only upcase }
  413.    numonly : boolean; { Set to TRUE to allow only numbers }
  414.    tlenmax : byte;    { Number of characters to display for string }
  415.    tstr    : string;  { Holds the object's entered string }
  416.   ------------------------------------------------------
  417.   constructor init(x,y,w,h,idn:integer;ch:char;fnc:boolean;t,t2:string;tmax:byte);
  418.  
  419.   Sets up the string object.
  420.  
  421.      X,Y    left-top position of the object
  422.      W,H    width and height of the object
  423.      IDN    the object's unique id number
  424.      CH     objects hot-key
  425.      FNC    TRUE if the hot-key is an extended character
  426.      T      title of the object
  427.      T2     string input text
  428.      TMAX   Number of maximum characters to display T2
  429.   ------------------------------------------------------
  430.   procedure drawitemobject;virtual;
  431.  
  432.   See Tbutton.drawitemobject
  433.   ------------------------------------------------------
  434.   procedure showpress;virtual;
  435.  
  436.   See Tbutton.showpress
  437.   ------------------------------------------------------
  438.   procedure filename(px,py:integer;var fname:string);
  439.  
  440.   Called from the method showpress.  Does the actual text
  441.   entry.
  442.  
  443.      PX,PY    Top-left Position of the text area
  444.      FNAME    string to change
  445.  
  446.      Text entry commands:
  447.  
  448.      ENTER or mouse button   - Finish typing
  449.      BACKSPACE               - Delete character before cursor
  450.      DEL                     - Delete character at cursor
  451.      HOME                    - Move to beginning of line
  452.      END                     - Move to end of line
  453.      Left arrow              - Move one character to the left
  454.      Right arrow             - Move one character to the right
  455. ───────────────────────────────────────────────────────────────────────────
  456. TCHECK - check box object
  457.  
  458.     esx,esy,           { width,height of check box within object }
  459.     epx,epy : integer; { (x,y) position of check box within object }
  460.     objectx,           { Same as TitleX,TitleY sets position of the }
  461.     objecty : itempos; {  check box position with in the object }
  462.     tchk    : boolean; { TRUE if the check box is checked }
  463.   ------------------------------------------------------
  464.   constructor init(x,y,w,h,idn:integer;ch:char;fnc:boolean;t:string;chk:boolean);
  465.  
  466.   Sets up the check box object.
  467.  
  468.      X,Y    left-top position of the object
  469.      W,H    width and height of the object
  470.      IDN    the object's unique id number
  471.      CH     objects hot-key
  472.      FNC    TRUE if the hot-key is an extended character
  473.      T      title of the object
  474.      CHK    set to TRUE to initially have the object checked
  475.   ------------------------------------------------------
  476.   procedure drawitemobject;virtual;
  477.  
  478.      See Tbutton.drawitemobject
  479.   ------------------------------------------------------
  480.   procedure show(on:boolean);virtual;
  481.  
  482.      See Tbutton.show
  483.   ------------------------------------------------------
  484.   procedure showpress;virtual;
  485.  
  486.      Displays the Check of the object
  487.  
  488.      See Tbutton.showpress
  489.   ----------------------------------------------------
  490.   procedure actionitemobject;virtual;
  491.  
  492.      This method toggles the check box. Then calls showpress
  493. ───────────────────────────────────────────────────────────────────────────
  494. TRADIO - radio (single selection) object
  495.  
  496.      group : integer;  { identifies the radio button group id number }
  497.  
  498.   Assign radio buttons with the same group id number to allow only one
  499.   radio button within a group to be checked.
  500.   ----------------------------------------------------
  501.   constructor init(x,y,w,h,idn,grp:integer;ch:char;fnc:boolean;t:string;chk:boolean);
  502.  
  503.   Sets up the radio box object.
  504.  
  505.      X,Y    left-top position of the object
  506.      W,H    width and height of the object
  507.      IDN    the object's unique id number
  508.      GRP    the radio button's group id number
  509.      CH     objects hot-key
  510.      FNC    TRUE if the hot-key is an extended character
  511.      T      title of the object
  512.      CHK    set to TRUE to initially have the object checked
  513.   ----------------------------------------------------
  514.   procedure showpress;virtual;
  515.  
  516.   Displays the check of the radio buttton
  517.   ----------------------------------------------------
  518.   procedure actionitemobject;virtual;
  519.  
  520.   Sets the radio button to CHECKED state and sets all other radio
  521.   buttons within the same group to the UNCHECKED state. Calls the
  522.   methods showpress for ALL radio buttons within the same group
  523. ───────────────────────────────────────────────────────────────────────────
  524. TSCROLL - scroll bar object
  525.  
  526.    horz    : boolean;  { TRUE - if horzontal scroll bar, FALSE - vertical }
  527.    tx1,ty1,            { tx1,ty1,tx2,ty2 - scrollable box area }
  528.    tx2,ty2,
  529.    pvlu,               { used internally }
  530.    siz,                { used internally }
  531.    bmin,bmax,          { MIN and MAX values of the scroll bar. Can not be }
  532.                        {  negative }
  533.    bpos,               { Scroll bar value. Always in the range BMIN..BMAX }
  534.    binc : integer;     { Value to increment,decrement when arrow area are }
  535.                        {  pressed }
  536.   ----------------------------------------------------
  537.   constructor init(x,y,w,h,idn,min,max,bi,bp:integer;hz:boolean);
  538.  
  539.   Sets up the scroll box object.  Scroll bars do not use hot-keys.
  540.  
  541.      X,Y    left-top position of the object
  542.      W,H    width and height of the object
  543.      IDN    the object's unique id number
  544.      MIN    minimum value for scroll bar
  545.      MAX    maximum value for scroll bar
  546.      BI     value of inc/dec for arrow areas
  547.      BP     initial starting postion of scroll bar
  548.      hz     TRUE - horzontal  FALSE - vertical scroll bar
  549.   ----------------------------------------------------
  550.   procedure showpress;virtual;
  551.  
  552.   Draws the scroll bar position
  553.   ----------------------------------------------------
  554.   procedure drawitemobject;virtual;
  555.  
  556.   See Tbutton.drawitemobject
  557.   ----------------------------------------------------
  558.   procedure redrawscroll;
  559.  
  560.   Redraws the scroll box pointer.
  561.   ----------------------------------------------------
  562.   function porp(vlu,max,min,p1,p2,wd:integer):integer;
  563.  
  564.   Calculates new scroll bar box position
  565. ───────────────────────────────────────────────────────────────────────────
  566. TPBOX  - Pick (selection) box object
  567.  
  568.   sh,st : plist;     { list of string objects }
  569.   lhstr : string;    { last string selected }
  570.   lhdat : longint;   { data of last string selected }
  571.   items : integer;   { max number of items to display }
  572.   ----------------------------------------------------
  573.   constructor init(x,y,w,i,idn:integer;t:string);
  574.  
  575.   Sets up the pick box object. Pick boxes do not use hot-keys.
  576.  
  577.      X,Y    left-top position of the object
  578.      W      width the object
  579.      I      max number of items to list
  580.      IDN    the object's unique id number
  581.      T      title of the object
  582.   ----------------------------------------------------
  583.   function ncheckhit(hx,hy,ohx,ohy:integer;item:Pobjlist):boolean;virtual;
  584.  
  585.   See Tbutton.ncheckhit
  586.   ----------------------------------------------------
  587.   procedure drawitemobject;virtual;
  588.  
  589.   See Tbutton.drawitemobject
  590.   ----------------------------------------------------
  591.   procedure additem(s:string;d:longint;draw:boolean);virtual;
  592.  
  593.   Adds an entry item to the list.  Each entry item has two fields
  594.   a string and longint item.  The string item is what is displayed. The
  595.   longint item can be used for your own use.
  596.  
  597.     S     String data to add
  598.     D     Longint data to add
  599.     DRAW  Set to TRUE if to update screen after adding.  If set to
  600.           FALSE, use the drawitemobject to update screen at a later time.
  601.   ----------------------------------------------------
  602.   function delitem(s:string;d:longint;draw:boolean):boolean;virtual;
  603.  
  604.   Deletes item from the list. The string and longint value both
  605.   most be equal (case-sensitive).  Returns TRUE if successful.
  606.  
  607.      S    String to search
  608.      D    Longint value to search
  609.      DRAW Set to TRUE if to update screen afer deleting.  If set to
  610.           FALSE, use the drawitemobject to update screen at a later time.
  611.  
  612.   ----------------------------------------------------
  613.   function getcount:integer;virtual;
  614.  
  615.   Returns the number of items in the list
  616.   ----------------------------------------------------
  617.   procedure show(on:boolean);virtual;
  618.  
  619.   See Tbutton.show
  620.   ----------------------------------------------------
  621.   destructor done;virtual;
  622.  
  623.   See Tbutton.done
  624. ───────────────────────────────────────────────────────────────────────────
  625. ───────────────────────────────────────────────────────────────────────────
  626. OTHER OBJECTS
  627. ───────────────────────────────────────────────────────────────────────────
  628. TKEY_IO = keyboard input object
  629.  
  630.   ch    : char;      { ASCII character pressed, #1 if no key pressed }
  631.   funct : boolean;   { TRUE if (ch) indicates an extended character, such }
  632.                      { as a function key }
  633.   ----------------------------------------------------
  634.   constructor init(h:char;f:boolean);
  635.  
  636.   Sets up the tkey_io object.
  637.      h:char;    initial value to set (ch)
  638.      f:boolean; initial value to set (funct)
  639.   ----------------------------------------------------
  640.   procedure inkey; virtual;
  641.  
  642.   Reads the keyboard buffer and sets the CH, FUNCT variables
  643.   ----------------------------------------------------
  644.   function apress : boolean; virtual;
  645.  
  646.   Returns TRUE if a key was pressed
  647.   ----------------------------------------------------
  648.   procedure clearbuffer; virtual;
  649.  
  650.   Clears the keyboard buffer, waits until no key is pressed
  651.   ----------------------------------------------------
  652.   destructor done; virtual;
  653.  
  654.   Deallocates the virtual object.
  655. ───────────────────────────────────────────────────────────────────────────
  656. Tmouse_IO = keyboard input object
  657.  
  658.   mpx,mpy,       { mouse current screen position }
  659.   opx,opy,       { mouse old position }
  660.   mop,           { mouse button press flag }
  661.   lmop,          { mouse old button press flag }
  662.   x,y,           { motion coordinate values, range not checked }
  663.   lx,ly:integer; { old motion coordinate value positions }
  664.   ----------------------------------------------------
  665.   constructor init(h:char;f:boolean;sx,sy,m:integer);
  666.  
  667.   Sets up the tmouse_io object.
  668.      h:char;        initial value to set (ch)
  669.      f:boolean;     initial value to set (funct)
  670.      sx,sx:char;    initial value to set (mpx,mpy)
  671.      m              initial value to set (mop)
  672.   ----------------------------------------------------
  673.   procedure inkey; virtual;
  674.  
  675.   Reads the keyboard buffer and mouse. Sets keyboard and
  676.   mouse variables.
  677.   ----------------------------------------------------
  678.   function apress : boolean; virtual;
  679.  
  680.   Returns TRUE if a key was pressed or a mouse button
  681.   is pressed
  682.   ----------------------------------------------------
  683.   function mousepressed : boolean; virtual;
  684.  
  685.   Returns TRUE if a mouse button is pressed
  686.   ----------------------------------------------------
  687.   procedure clearbuffer; virtual;
  688.  
  689.   Clears the keyboard buffer, waits until no key and no mouse
  690.   button is pressed
  691.   ----------------------------------------------------
  692.   destructor done; virtual;
  693.  
  694.   Deallocates the virtual object.
  695. ───────────────────────────────────────────────────────────────────────────
  696. ───────────────────────────────────────────────────────────────────────────
  697. OTHER FUNCTIONS
  698. ───────────────────────────────────────────────────────────────────────────
  699. function strlen(s:string):word;
  700.  
  701.    Returns a length of a string in pixels.
  702.  
  703.    S       String to find width
  704. ───────────────────────────────────────────────────────────────────────────
  705. procedure textpos(title:string;tx1,ty1,tx2,ty2:integer;txpos,typos:itempos;var ux,uy:integer);
  706.  
  707.    Sets a string (x,y) position within a rectangular area.
  708.  
  709.    TITLE     string to adjust
  710.    tx1,ty1   top-left position of rectangle
  711.    tx2,ty2   bottom-right position of rectangle
  712.    txpos     horzontal position
  713.    typos     vertical position
  714.    ux,uy     return coordinate to place text
  715.  
  716.    EXAMPLE:
  717.  
  718.       var
  719.          x,y : integer;
  720.       begin
  721.          textpos('Hello',10,10,100,100,center,center,x,y);
  722.          putletter(x,y,15,'Hello');
  723.       end;
  724.  
  725.       Displays the text Hello centered within a box
  726. ───────────────────────────────────────────────────────────────────────────
  727. procedure pointpos(tx1,ty1,tx2,ty2:integer;txpos,typos:itempos;var ux,uy:integer);
  728.  
  729.    Sets point within a rectangular area.
  730.  
  731.    tx1,ty1   top-left position of rectangle
  732.    tx2,ty2   bottom-right position of rectangle
  733.    txpos     horzontal position
  734.    typos     vertical position
  735.    ux,uy     return coordinate to place point
  736.  
  737.    EXAMPLE:
  738.  
  739.       var
  740.          x,y : integer;
  741.       begin
  742.         pointpos(10,10,100,100,center,center,x,y);
  743.         pset(x,y,15);
  744.       end;
  745.  
  746.       Plots a point centered within a box
  747. ───────────────────────────────────────────────────────────────────────────
  748. procedure drawstring(x,y:integer;s:string;c1,c2:byte);
  749.  
  750.   Same as spx_txt.drawstring
  751.  
  752. ───────────────────────────────────────────────────────────────────────────
  753. procedure vgaborder(x1,y1,x2,y2:integer;border:boolean);
  754.  
  755.   Draws a 3D button rectangle using the defined system colors.  Where
  756.   the top and left sides are highlighted.
  757.  
  758.   x1,y1   top-left position of rectangle
  759.   x2,y2   bottom-right position of rectangle
  760.   border  set to TRUE to draw border, FALSE erases with system background
  761.           color cl[sysc_background]
  762. ───────────────────────────────────────────────────────────────────────────
  763. procedure vgainvr(x1,y1,x2,y2:integer;border:boolean);
  764.  
  765.   Same as vgaborder. Draws a 3D button rectangle using the defined system
  766.   colors.  Where the bottom and right sides are highlighted.
  767.  
  768.   x1,y1   top-left position of rectangle
  769.   x2,y2   bottom-right position of rectangle
  770.   border  set to TRUE to draw border, FALSE erases with system background
  771.           color cl[sysc_background]
  772. ───────────────────────────────────────────────────────────────────────────
  773. procedure vgarect(x1,y1,x2,y2:integer);
  774.  
  775.   Draws a button rectangle using the system colors.  Rectangle is actually
  776.   2 pixels smaller on each side.
  777.  
  778.   x1,y1   top-left position of rectangle
  779.   x2,y2   bottom-right position of rectangle
  780. ───────────────────────────────────────────────────────────────────────────
  781. procedure vgabox(x1,y1,x2,y2:integer);
  782.  
  783.   Draws a button filled box using the system colors.  Rectangle is actually
  784.   2 pixels smaller on each side.
  785.  
  786.   x1,y1   top-left position of rectangle
  787.   x2,y2   bottom-right position of rectangle
  788.  
  789. ───────────────────────────────────────────────────────────────────────────
  790. function onwin(x,y,w,h:integer;border:boolean):boolean;
  791.  
  792.   Draws a popup (non-moveable) window using the default system colors.  The
  793.   area behind the window is saved to a window stack.  Returns TRUE if
  794.   successful.
  795.  
  796.   x,y     top-left positon of window
  797.   w,h     width and height of window (in pixels)
  798.   border  set to TRUE to drawa border around window
  799.  
  800. ───────────────────────────────────────────────────────────────────────────
  801. procedure offwin;
  802.  
  803.   Removes the last drawn popup window by restoring the saved background.
  804.   If you want to deallocate the window but keep the window drawn on the
  805.   screen set the flag (WinUpdate) to FALSE before the procedure offwin.
  806.  
  807.   EXAMPLE:
  808.  
  809.     onwin(10,10,150,50,true);   { display a window }
  810.     { draw items on window }
  811.     { do popup window stuff }
  812.     offwin;                     { remove popup window }
  813. ───────────────────────────────────────────────────────────────────────────
  814. procedure message(s:string;wait:boolean);
  815.  
  816.   Displays a popup window with a one line message.
  817.  
  818.   s       string message to display.
  819.   wait    set to TRUE to add a push button to window.  The user must press
  820.            the button or the ENTER key to remove the window and continue.
  821.           set to FALSE to display the message and continue.  The window
  822.           can be removed by calling the procedure offwin.
  823.  
  824.   EXAMPLE
  825.  
  826.       message('About to load, press ENTER',TRUE); { waits for user }
  827.  
  828.       message('Loading file, please wait...',FALSE); { display message }
  829.       { load file }
  830.       offwin;       { remove message window }
  831. ───────────────────────────────────────────────────────────────────────────
  832. function yes(msg:string):boolean;
  833.  
  834.    Displays a popup window with two buttons (YES and NO). Returns TRUE if the user
  835.    selects the YES button.
  836.  
  837.    msg     a string to display in the box.
  838.  
  839.    EXAMPLE
  840.  
  841.    if yes('Do you want to draw a line?')
  842.      then line(0,0,100,100,14);
  843.  
  844.    Draws a line if the user selects the YES button.
  845. ───────────────────────────────────────────────────────────────────────────
  846. function diskdo(x,y:integer;fpath,mask,title:string;loading:boolean):string;
  847.  
  848.    Displays the files selection popup window.
  849.  
  850.    x,y      top left position of window
  851.    fpath    default file path
  852.    mask     default file 3 character extension.
  853.    tite     a title for the popup window
  854.    loading  set to TRUE for loading files or FALSE for saving files.
  855.  
  856.    Returns the file name (with path) or an empty string if the user
  857.    cancels.  If the flag (loading) is set to FALSE, the function will
  858.    prompt to overwrite the file when the user selects OK.  Selecting NO
  859.    will return to the file selection window.  YES will continue.  This
  860.    checking can be disabled by setting the flag (DiskVerify) to FALSE before
  861.    the call to diskdo function.
  862.  
  863. ───────────────────────────────────────────────────────────────────────────
  864. procedure finddrives;
  865.  
  866.   Finds all of the available drives. Sets the following two variables with
  867.   the drives in the machine:
  868.  
  869.     drives   a string with all available drives
  870.   driveset   a set of 'A'..'Z' with all available drives set
  871. ───────────────────────────────────────────────────────────────────────────
  872. function writeable(pth:string):boolean;
  873.  
  874.    Returns TRUE if the path is writeable. (able to save files)
  875.  
  876.    pth   A path to check if it is writeable.
  877. ───────────────────────────────────────────────────────────────────────────
  878. procedure adjustmenupalette;
  879.  
  880.    Reads the current VGA palette then remaps the system colors.
  881. ───────────────────────────────────────────────────────────────────────────
  882.  
  883.